<?php
	
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Db');
Zend_Loader::loadClass('Zend_Db_Table');
Zend_Loader::loadClass('Zend_Config_Ini');
Zend_Loader::loadClass('Zend_Locale');
	
class Globals{
	private static $_db = null;
	private static $_config = null;
	private static $_locale = null;
	
	public static function getDBConnection(){
		if(self::$_db != null){
			return self::$_db;
		}
		
		self::$_db = Zend_Db::factory('Pdo_Mysql', array('host'=>Globals::getConfig()->db->host, 'username'=>Globals::getConfig()->db->username, 'password'=>Globals::getConfig()->db->password, 'dbname'=>Globals::getConfig()->db->dbname, 'driver_options'=>array(PDO::MYSQL_ATTR_INIT_COMMAND=>'SET NAMES UTF8;')));
		
		Zend_Db_Table::setDefaultAdapter(self::$_db);
		
		return(self::$_db);
	}
	
	public static function getConfig(){
		if (self::$_config != null) {
			return self::$_config;
		}
		self::$_config = new Zend_Config_Ini(dirname(__FILE__).DIRECTORY_SEPARATOR.'config.ini', 'main');
		
		return self::$_config;
	}
	
	public static function getLocale(){
		if (self::$_locale != null) {
			return self::$_locale;
		}
		$locale = new Zend_Locale(Zend_Locale::BROWSER, true);
		
		self::$_locale = $locale->getLanguage();
		
		
		return self::$_locale;
	}
	
}
	
	
?>